<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Welcome to Q&Q's Website</title>
<LINK href="../style.css" rel=stylesheet>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<style type="text/css">
body,td,th {
	font-family: "Times New Roman", Times, serif;
}

a {
	font-family: "Times New Roman", Times, serif;
}
</style>
</head>
<body bottomMargin=0 leftMargin=0 topMargin=0 rightMargin=0>
	<TABLE width="1024" height="768" border=0 cellSpacing=0 cellPadding=0
		align=center>
		<TR HEIGHT="150">
			<TD Align=center colspan=5><%@include file="../top.jsp"%>
			</TD>
		</TR>

		<!---Khai báo khoảng phân cách--->
		<TR HEIGHT="2">
			<TD colspan=5 bgcolor="white"></TD>
		</TR>

		<TR HEIGHT=100%>
			<TD vAlign="top" width="150"><%@include file="../left.jsp"%>
			</TD>

			<!---Khai báo khoảng phân cách--->
			<TD bgcolor=white width="2"></TD>
			<TD vAlign=top width="720" bgcolor=white><%!boolean notExist(int a[], int b) {
		for (int i = 0; i < a.length; i++) {
			if (a[i] == b)
				return false;
		}
		return true;
	}%>
				<table width=720 height=100% border=0>
					<%
						Class.forName("com.mysql.jdbc.Driver");
						Connection con = null;
						Statement smt = null;
						ResultSet rst = null;
						int i = 0;
						int a[] = new int[9];
						for (int k = 0; k < 9; k++)
							a[k] = 10;
						try {
							String username = "root";
							String password = "Vietyeutam1112";
							String url = "jdbc:mysql://127.0.0.1:3306/ghmotel";
							con = DriverManager.getConnection(url, username, password);
							System.out.println("Da ket noi CSDL");
							smt = con.createStatement();
							// 		while (i < 9) {
							//int j = (int)((Math.random()*10)%6);
							//if (notExist(a, j)) 
							switch (0) {
							case 0:
								rst = smt.executeQuery("select * from room");
								break;
							// 				case 1: rst = smt.executeQuery("select * from room where room_id=102"); break;
							// 				case 2: rst = smt.executeQuery("select * from room where room_id=201"); break;
							// 				case 3: rst = smt.executeQuery("select * from room where room_id=202"); break;
							// 				case 4: rst = smt.executeQuery("select * from room where room_id=203"); break;
							// 				case 5: rst = smt.executeQuery("select * from room where room_id=301"); break;
							// 				case 6: rst = smt.executeQuery("select * from room where room_id=302"); break;
							}
							;
							while (rst.next()) {
								i++;
								if (i == 1 || i == 6) {
									out.println("<tr>");
								}
								String img = "/BanHang/image/free.jpg";
								String detail = "Thuê phòng này";
								Statement st = con.createStatement();
								ResultSet rs = st.executeQuery("CALL getRoomInfo("
										+ rst.getString(1) + ")");

								while (rs.next()) {
									img = "/BanHang/image/busy.jpg";
									detail = "Xem chi tiết";
								}

								out.println("<td width=240 align=center>" + "<img src="
										+ img + " width=200><br><font color=red size= 4 > "
										+ rst.getString(1) + "</font><br> Tầng: "
										+ rst.getString(2) + "" + "<br><a href="
										+ "ru_detail.jsp?room_id=" + rst.getString(1) + ">"
										+ detail + "</a></td>");
								if (i == 2 || i == 7) {
									out.println("</tr>");
									System.out.println(i);
								}
								// 			}
								//a[i] = j;
								// 			if(i%3 == 0) out.println("<tr>");	
								// 			out.println("<td width=240 align=center>"+"<img src="+rst.getString(1)+" width=200><br>"+rst.getString(2)+"<br><font color=red>"+rst.getString(3)+" đ</font>"+"<br><a href="+"productdetail.jsp?ID="+rst.getString(1)+">Chi tiết</a></td>");
								// 			i++;
								// 			if(i%3 == 0) {
								// 				out.println("</tr>");
								// 				System.out.println(i);
								// 			}
							}
							con.close();
						} catch (Exception e) {
						}
					%>
				</table></TD>

			<!---Khai báo khoảng phân cách--->
			<TD bgcolor=white width="2"></TD>
			<TD vAlign=top width="150"><%@include file="../right.jsp"%>
			</TD>
		</TR>

		<!---Khai báo khoảng phân cách--->
		<TR HEIGHT="2">
			<TD colspan=5 bgcolor=white></TD>
		</TR>

		<TR HEIGHT="50">
			<TD colspan=5 align=center><%@include file="../bottom.jsp"%>
			</TD>
		</TR>
	</TABLE>
</body>
</html>